package com.youxin.cpcenter.controller;

import com.youxin.busfoundation.bean.ResponseObject;
import com.youxin.cpcenter.bean.RequestSalesfunnelBean;
import com.youxin.cpcenter.common.log.LogMethod;
import com.youxin.cpcenter.service.SalesFunnelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Objects;

/**
 * @desc 销售漏斗控制器
 * @anthor Krsi.wang
 * @date 2017-12-09
 */
@RestController
public class SalesFunnelController extends BaseController{

    @Autowired
    private SalesFunnelService salesFunnelService;

    /**
     * @desc 销售漏斗
     * @param request
     * @param httpServletResponse
     * @param requestBean
     * @return
     */
    @LogMethod(id="ent.api.salesfunnel",eventContent={})
    @RequestMapping(value = "/api/salesfunnel", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseObject totalSalesFunnel(HttpServletRequest request, HttpServletResponse httpServletResponse,
                                           @RequestBody RequestSalesfunnelBean requestBean)  {
        try {
            return salesFunnelService.totalSalesFunnel(requestBean);
        } catch (Exception e) {
            logger.error("/totalSalesFunnel异常", e);
            return ResponseObject.systemError(e);
        }
    }

    /**
     * @desc 销售漏斗-跟进人列表
     * @param request
     * @param httpServletResponse
     * @return
     */
    @LogMethod(id="ent.api.salesfunnel.followup",eventContent={})
    @RequestMapping(value = "/api/salesfunnel/followlist", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseObject followupList(HttpServletRequest request, HttpServletResponse httpServletResponse)  {
        try {
            return salesFunnelService.followupList();
        } catch (Exception e) {
            logger.error("/followupList", e);
            return ResponseObject.systemError(e);
        }
    }

}
